package LeetCode.leetcode383;

public class Review1 {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] map = new int[26];
        char cur;
        for (int i = 0; i < magazine.length(); i++) {
            cur = magazine.charAt(i);
            map[cur - 'a'] += 1;
        }
        for (int i = 0; i < ransomNote.length(); i++) {
            cur = ransomNote.charAt(i);
            if (map[cur - 'a'] > 0) {
                map[cur - 'a'] -= 1;
            } else {
                return false;
            }
        }
        return true;
    }
}
